<?php
/**
 * @description : the message box show.
 * @author      : stephen.mo
 * @date        : 2010/09/07
 */
require_once "TVB/OAuth/common.inc.php";
#ini_set('display_errors','on');

$lang              = (isset($_REQUEST['lang'])) ? $_REQUEST['lang'] : OAuthConfig::DEFAULT_SUPPORT_LANG;
$state             = (isset($_REQUEST['state'])) ? $_REQUEST['state'] : NULL;
$flag              = (isset($_REQUEST['flag'])) ? $_REQUEST['flag'] : NULL;
$act               = (isset($_REQUEST['act'])) ? $_REQUEST['act'] : ((empty($state)) ? 'success' : 'failure');

//setting url.
$base_server_path  = OAuthConfig::OAuthDomainUrl($_SERVER);
$jqtouch_url       = $base_server_path.OAuthModelConfig::DEFAULT_MOBILE_TEMPLATE;
$header_url        = $base_server_path.OAuthConfig::DEFAULT_HEADER_URL;
$reback_url        = (isset($_REQUEST['reback_url'])) ? $_REQUEST['reback_url'] : NULL;
$confirm_url       = $header_url.'?oauth_reback='.urlencode($reback_url);

//page info vars.
$msg_page_info     = OPI::$other_page_info;
$msg_error_ids     = $msg_page_info[$lang]['msg_error_ids'];
$error_codes       = OPI::$errorCodeTxt[$lang];
$payment_buttons   = OPI::$payment_button_info;

//setting the form datas into array.
$using_real_env    = OAuthModelConfig::USING_TEMPLATE_ON_REAL_ENV;
$page              = OAuthModelConfig::M_PAGE_OF_MESSAGE;

$form = array();
$form['lang']        = $lang;
$form['title']       = $msg_page_info[$lang]['page_title'];
$form['act']         = $act;
$form['flag']        = $flag;
$form['error_codes'] = $error_codes;

//succ
$succ = array();
$succ['confirm_url']       = isset($_REQUEST['confirm_url']) ? $_REQUEST['confirm_url'] : NULL;
$succ['msg_txt']           = $msg_page_info[$lang][$state];
$succ['goback_url']        = $header_url.'?oauth_reback='.urlencode($call_back);
$succ['order_ref']         = (isset($_REQUEST['order_ref'])) ? $_REQUEST['order_ref'] : NULL;
$succ['period']            = (isset($_REQUEST['period'])) ? " '".base64_decode($_REQUEST['period'])."' " : NULL;
$succ['succ_msg_txt']      = str_replace('{%SEVICE%}',$succ['period'],$msg_page_info[$lang]['msg_succ_payment']);
$succ['msg_receipt_no']    = $msg_page_info[$lang]['msg_receipt_no'];
$succ['msg_enjoy']         = $msg_page_info[$lang]['msg_enjoy'];
$succ['msg_thirdpayment']  = $msg_page_info[$lang]['msg_third_payment'];

//errors
$error = array();
$error['msg_txt']          = $msg_page_info[$lang]['msg_error_txt'];
$error['skip_url']         = $header_url.'?oauth_reback='.urlencode($_REQUEST['call_back']);
$error['restart_url']      = (isset($_REQUEST['retry_url'])) ? $_REQUEST['retry_url'] : '#';
$error['retry_url']        = (isset($_REQUEST['retry_url'])) ? $_REQUEST['retry_url'] : NULL;
$error['confirm_url']      = $confirm_url;

$error['flag_txt']         = $msg_error_ids[$flag]['txt'];
$error['current_ids']      = json_decode($_REQUEST['errids'],true);
$error['error_ids']        = $msg_error_ids[$flag]['error_id'];
$error['login_id']         = isset($_REQUEST['login_id']) ? $_REQUEST['login_id'] : NULL;
$error['userPkgInfo']      = OAuthModel::getInstance()->getUserCurrentPlan($login_id,$lang);

$form['succ']  = $succ;
$form['error'] = $error;
$form['button']['close']   = array('value'=>$payment_buttons[$lang]['close'],'link'=>NULL);
$form['button']['confirm'] = array('value'=>$payment_buttons[$lang]['confirm'],'link'=>NULL);
$form['button']['return']  = array('value'=>$payment_buttons[$lang]['return'],'link'=>NULL);
$form['button']['retry']   = array('value'=>$payment_buttons[$lang]['retry'],'link'=>NULL);
$form['button']['goback']  = array('value'=>$payment_buttons[$lang]['goback'],'link'=>NULL);

//include thie template for plan cmodel page.
include "..".OAuthModelConfig::DEFAULT_MOBILE_TEMPLATE.OAuthModelConfig::$mobile_teplate_page[$page];

?>

